search engine: Don't crawl remote locations
authorMatthias Clasen <mclasen@redhat.com>
Fri, 24 Jul 2015 19:52:37 +0000 (15:52 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 27 Jul 2015 12:07:39 +0000 (08:07 -0400)
This is slow, and causes too much network I/O.
So skip locations that look like they are remote.

gtk/gtksearchenginesimple.c

index d61bb3059d0631011b302c273700e9d16e7d3838..4db84ce7840747e790ee588277a4997d6fbccea1 100644 (file)
@@ -26,6 +26,7 @@
 #include <gdk/gdk.h>
 
 #include "gtksearchenginesimple.h"
+#include "gtkfilesystem.h"
 #include "gtkprivate.h"
 
 #include <string.h>
@@ -87,12 +88,19 @@ gtk_search_engine_simple_dispose (GObject *object)
   G_OBJECT_CLASS (_gtk_search_engine_simple_parent_class)->dispose (object);
 }
 
+static void
+queue_if_local (SearchThreadData *data,
+                GFile            *file)
+{
+  if (!_gtk_file_consider_as_remote (file))
+    g_queue_push_tail (data->directories, g_object_ref (file));
+}
+
 static SearchThreadData *
 search_thread_data_new (GtkSearchEngineSimple *engine,
                        GtkQuery              *query)
 {
   SearchThreadData *data;
-  GFile *location;
 
   data = g_new0 (SearchThreadData, 1);
 
@@ -100,12 +108,7 @@ search_thread_data_new (GtkSearchEngineSimple *engine,
   data->directories = g_queue_new ();
   data->query = g_object_ref (query);
   data->recursive = _gtk_search_engine_get_recursive (GTK_SEARCH_ENGINE (engine));
-  location = gtk_query_get_location (query);
-  if (location)
-    g_object_ref (location);
-  else
-    location = g_file_new_for_path (g_get_home_dir ());
-  g_queue_push_tail (data->directories, location);
+  queue_if_local (data, gtk_query_get_location (query));
 
   data->cancellable = g_cancellable_new ();
 
@@ -257,7 +260,7 @@ visit_directory (GFile *dir, SearchThreadData *data)
       if (data->recursive &&
           g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY &&
           !is_indexed (data->engine, child))
-        g_queue_push_tail (data->directories, g_object_ref (child));
+        queue_if_local (data, child);
     }
 
   g_object_unref (enumerator);